<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">

	<ui:composition template="/template/layout2.xhtml">
	<ui:define name="conteudo">
		<br/><br/>
		<div id="path">
			<h1>Cadastro Noticia</h1>
			<hr />
			
		</div>
		
		<h:form><br/><br/><br/>
		<p:messages autoUpdate="true"/>
		<fieldset>
		<legend>Dados</legend>
		<br /><br/>
		<h:panelGrid columns="3">
			<h:outputLabel value="Titulo:" for="titulo" styleClass="label"/>
			<h:inputText id="titulo" class="rotulos" value="#{noticiaBean.noticia.titulo}" required="true" requiredMessage="* O campo [Titulo] é obrigatório!"/>
			<br/>
				
			<h:outputLabel value="Enunciado:" for="enunciado" styleClass="label"/>
			<h:inputTextarea id="enunciado" value="#{noticiaBean.noticia.conteudo}" required="true" requiredMessage="* O campo [Enunciado] é obrigatório!"  />	
			<br/>
	    </h:panelGrid>  
    		<br /><br/>
    		<h:commandButton class="botaolimpar" value="Limpar" image="../resources/imagens/botoes/botao-limpar.png" immediate="true">
			<f:ajax render="@form"></f:ajax>	
			</h:commandButton>	
            <h:commandButton class="botaosalvar" value="Salvar" image="../resources/imagens/botoes/botao-salvar.png" action="#{noticiaBean.actionCadastrar}" ></h:commandButton>	      		
		</fieldset>
		</h:form>
		<div><br/></div>
		<h:form>
			<h:dataTable styleClass="tabela" headerClass="cabecalho" columnClasses="ultimo,primeiro" value="#{noticiaBean.noticias}" var="noti">
				<h:column>
					<f:facet name="header">
						<h:outputText value="Id" />
					</f:facet>
					<h:outputText value="#{noti.id}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Titulo" />
					</f:facet>
					<h:outputText value="#{noti.titulo}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Conteúdo" />
					</f:facet>
					<h:outputText value="#{noti.conteudo}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Ação" />
					</f:facet>
					<h:commandLink value="" title="Editar" immediate="true">
						<f:setPropertyActionListener target="#{noticiaBean.noticia}" value="#{noti}" />
						<h:graphicImage library="imagens" name="editar.png" />
					</h:commandLink>
					
					<h:commandLink value="" action="#{noticiaBean.actionRemover}" immediate="true" title="Remover" >
						<f:setPropertyActionListener target="#{noticiaBean.noticia}" value="#{noti}" />
						<h:graphicImage library="imagens" name="ic_remover.gif" />
					</h:commandLink>
				</h:column>
			</h:dataTable>
		</h:form>
		
		</ui:define>
	</ui:composition>
</html>